package com.mge.humitureproj.dao;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.mge.humitureproj.entity.HumitureExRecord;
import org.apache.ibatis.annotations.Select;

/**
 * 温湿度异常记录表(HumitureExRecord)表数据库访问层
 *
 * @author makejava
 * @since 2025-05-22 11:42:03
 */
@Mapper
public interface HumitureExRecordDao extends BaseMapper<HumitureExRecord> {

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<HumitureExRecord> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<HumitureExRecord> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<HumitureExRecord> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<HumitureExRecord> entities);


    @Select("select top 1 * from humiture_ex_record where regional_id_address = #{regionalIdAddress} order by record_date desc")
    HumitureExRecord selectByRegionalIdAddress(@Param("regionalIdAddress") String regionalIdAddress);

}

